import { useUserStore } from '@/store';
import { request } from '@/utils/request';
import CRUD from '@/utils/request/CRUD';
import axios from 'axios';
// 用户仓库
const userStore = useUserStore();

// 人工费用子CRUD
export const laborCostsCRUD = CRUD('/system/budget-labor-costs-data');

// 人工费用主
export const budgetLaborCostsCRUD = CRUD('/system/budget-labor-costs');

// 导入人工费
export function importLaborCostsData(data: Record<string, any>) {
  return axios.post(`${import.meta.env.VITE_API_URL}${import.meta.env.VITE_API_URL_PREFIX}/system/budget-labor-costs-data/import?companyId=${data.companyId}&laborCostsId=${data.laborCostsId}`,
    data.formData,{
      headers: {
        'Content-Type': 'multipart/form-data',
        Authorization: `Bearer ${userStore.token}`,
        'tenant-id': userStore.tenantId
      },
    }
   );
}
// 获取下载模板
export function getimportTemplateLaborCostsData() {
  return request.get({
    url: '/system/budget-labor-costs-data/get-import-template',
    responseType: 'blob',
  },{
    isTransformResponse: false,
  });
}
